<template>
  <div class="step">
    <div v-if="taskTime.closeTime" class="close" :style="{left: 16.6 * active - 8.3 +'%'}">
      <div class="line_y" />
      <div class="line_x" />
      <div class="close_content">
        <div class="circle" />
        <p>关闭</p>
        <p>{{ taskTime.closeTime }}</p>
      </div>
    </div>
    <el-steps :active="active" align-center>
      <el-step
        v-for="item in taskTimeList"
        :key="item.id"
        :title="item.title"
        :description="taskTime[item.value]"
      />
    </el-steps>
  </div>
</template>
<script>
export default {
  props: {
    taskTime: {
      type: Object,
      default: () => { }
    }
  },
  data() {
    return {
      taskTimeList: [
        {
          id: 1,
          title: '待付款',
          value: 'payTime'
        },
        {
          id: 2,
          title: '已发布',
          value: 'releaseTime'
        },
        {
          id: 3,
          title: '已开工',
          value: 'startTime'
        },
        {
          id: 4,
          title: '已完工',
          value: 'endTime'
        },
        {
          id: 5,
          title: '已支付',
          value: 'sureTime'
        },
        {
          id: 6,
          title: '已评价',
          value: 'appraiseTime'
        }
      ]
    }
  },
  computed: {
    active: function() {
      let active = 0
      this.taskTimeList.map((item, i) => {
        if (this.taskTime) {
          if (this.taskTime[item.value]) {
            active = i + 1
          }
        }
      })
      return active
    }
  },
  methods: {

  }
}
</script>
<style lang="scss" scoped>
.step {
  position: relative;
  padding-top: 100px;
}
.close {
  position: absolute;
  top: 5px;
  left: 8.3%;
  display: flex;
  align-items: flex-start;
  .line_y {
    width: 5px;
    height: 100px;
    background: #eeeeee;
  }
  .line_x {
    width: 100px;
    height: 5px;
    background: #eeeeee;
  }
  .close_content {
    margin-top: -15px;
    .circle {
      width: 30px;
      height: 30px;
      background: #eeeeee;
      border-radius: 40px;
    }
    p {
      line-height: 15px;
      height: 20px;
    }
  }
}
</style>
